<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>链式编程</title>
    <script src="../jquery/jquery.v3.7.1.js"></script>
</head>
<body>
    <div>
        <button>按钮1</button>
        <button>按钮2</button>
        <button>按钮3</button>
        <button>按钮4</button>
        <button>按钮5</button>
        <button>按钮6</button>
        <button>按钮7</button>
    </div>
    <script>
        // 链式编程
        // 1.链式编程原理：将每个方法都返回this
        // 2.链式编程的作用：简化代码，使代码更优雅，提高开发效率
        // 3.链式编程的缺点：可读性差，调试困难
        $(function(){
            $('button').click(function(){
                $(this).css('background-color','red').siblings().css('background-color','')
            })
        })
    </script>
</body>
</html>